Skip to content

Remove retired earmark and unused phoenix_storybook dependencies#4886

Merged
stuartc merged 6 commits into
mainfrom
4878-remove-earmark
Jun 26, 2026
Merged

Remove retired earmark and unused phoenix_storybook dependencies#4886
stuartc merged 6 commits into
mainfrom
4878-remove-earmark

Conversation

@midigofrank

@midigofrank midigofrank commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Description

This PR removes two retired/unused dev dependencies flagged by our dependency
audits. They're handled together because the only thing still pulling in the
retired earmark markdown library was phoenix_storybook — so removing both in
one pass clears earmark entirely.

earmark → mdex (#4878)

Replace the direct earmark dependency with mdex for rendering AI assistant
message content. earmark is retired and unmaintained; mix hex.audit flags
it.

mdex node structs cannot hold arbitrary HTML attributes, so per-element
Tailwind classes are now injected into the rendered HTML instead of via AST
manipulation. Raw HTML passthrough and the raw-content fallback are preserved,
and the language- prefix on code blocks is stripped to keep earmark's previous
output.

Remove phoenix_storybook (#4846)

phoenix_storybook 0.9.2 was the last consumer of the retired earmark (it
pulls it in as a dev-only transitive dep), and it also carried three open
advisories flagged by mix deps.audit (critical RCE via HEEx injection,
atom-table DoS, PubSub topic injection). It was dev-only with no production
exposure, and storybook was dormant — only three demo stories existed and
nothing had changed since the 2023 prototype. Rather than upgrade to 1.1.0, the
package is removed entirely, which also lets mix deps.unlock --unused drop
earmark from the lockfile:

  • Drop the dep and its dev-only routes, delete the backend module, stories, and
    assets, and strip the esbuild/tailwind/live-reload config.
  • Clear the storybook advisory IDs from the CI mix deps.audit ignore list,
    leaving only the cowlib advisory (no patch available yet).
  • Remove now-orphaned lock entries via mix deps.unlock --unused.

Closes #4878
Closes #4846

Validation steps

  1. mix deps.audit reports no vulnerabilities (only the cowlib advisory remains
    ignored in CI).
  2. iex -S mix phx.server boots in dev with no storybook route errors.
  3. The AI assistant still renders markdown responses correctly (code blocks,
    raw HTML, fallback content).

AI Usage

Please disclose whether you've used AI anywhere in this PR (it's cool, we just
want to know!):

  • I have used Claude Code
  • I have used another model
  • I have not used AI

You can read more details in our
Responsible AI Policy

Pre-submission checklist

  • I have performed an AI review of my code (we recommend using /review
    with Claude Code)
  • I have implemented and tested all related authorization policies.
    (e.g., :owner, :admin, :editor, :viewer)
  • I have updated the changelog.
  • I have ticked a box in "AI usage" in this PR

Replace the direct earmark dependency with mdex for rendering AI
assistant message content. earmark is retired and unmaintained;
mix hex.audit flags it.

mdex node structs cannot hold arbitrary HTML attributes, so per-element
Tailwind classes are now injected into the rendered HTML instead of via
AST manipulation. Raw HTML passthrough and the raw-content fallback are
preserved, and the language- prefix on code blocks is stripped to keep
earmark's previous output.

earmark remains a dev-only transitive dependency of phoenix_storybook
0.9.2 until that is upgraded to 1.2+ (which requires Phoenix 1.8).
@github-project-automation github-project-automation Bot moved this to New Issues in Core Jun 22, 2026
phoenix_storybook 0.9.2 carried three open advisories flagged by
mix deps.audit (critical RCE, atom-table DoS, PubSub topic injection).
It was dev-only with no production exposure, and storybook was dormant:
only three demo stories existed and nothing had changed since the 2023
prototype. Remove the package rather than upgrade to 1.1.0.

Drop the dep and its dev routes, delete the backend module, stories, and
assets, and strip the esbuild/tailwind/live-reload config. Clear the
storybook advisory IDs from the CI deps.audit ignore list, leaving only
the cowlib advisory (no patch available yet). Remove now-orphaned lock
entries via mix deps.unlock --unused.
@midigofrank midigofrank changed the title Migrate off retired earmark markdown dependency Remove retired earmark and unused phoenix_storybook dependencies Jun 26, 2026
@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.5%. Comparing base (3c86ddf) to head (e316fe9).

Additional details and impacted files
@@           Coverage Diff           @@
##            main   #4886     +/-   ##
=======================================
- Coverage   90.5%   90.5%   -0.0%     
=======================================
  Files        445     445             
  Lines      22752   22746      -6     
=======================================
- Hits       20589   20580      -9     
- Misses      2163    2166      +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

MDEx emits the standard `<code class="language-javascript">` for fenced
code blocks. We were rewriting it back to Earmark's old bare
`<code class="javascript">`, but nothing consumes that class (no syntax
highlighter is wired up, and the markdown CSS targets `pre code` by
element), so keep MDEx's conventional output instead.
@midigofrank midigofrank self-assigned this Jun 26, 2026
The earmark→mdex migration left MDEx running as plain CommonMark, which
silently dropped the GFM features earmark rendered by default. Assistant
replies containing markdown tables showed as raw pipe text, strikethrough
and bare-URL autolinks stopped working.

Enable the table, strikethrough, autolink, and tasklist extensions to
restore the prior rendering, and add a regression test covering them.
@midigofrank midigofrank marked this pull request as ready for review June 26, 2026 09:24
@github-actions

Copy link
Copy Markdown

Security Review ✅

  • S0 (project scoping): N/A — diff only swaps the markdown renderer in ai_assistant/component.ex, removes dev-only Storybook wiring (router.ex, storybook.ex, storybook/*), and adjusts config/tests; no new queries or web entrypoints over project-scoped resources.
  • S1 (authorization): N/A — no new handle_event/controller actions; formatted_content/1 only re-renders message text already shown to the same user.
  • S2 (audit trail): N/A — no inserts/updates/deletes on workflows, credentials, project settings, or other config resources.

@midigofrank midigofrank requested review from elias-ba and stuartc June 26, 2026 09:27

@stuartc stuartc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved, nice work. Conditional on whether the JS code formatting (colours) still works correctly.

@stuartc stuartc merged commit b1d14e3 into main Jun 26, 2026
8 checks passed
@stuartc stuartc deleted the 4878-remove-earmark branch June 26, 2026 12:27
@github-project-automation github-project-automation Bot moved this from New Issues to Done in Core Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Migrate off retired earmark markdown dependency Remove phoenix_storybook dependency and clear deps.audit skip

2 participants